import app from "../../app";
import manage_EquipStrengthen from "../../master/model/manage/manage_EquipStrengthen";
import { MsgAction, template, Tpl_propEquip_look } from "../../shared/master/MsgAction";
import { player, wallet_key } from "../fight/body/player";
import { equip } from "../fight/equip/equip";
import { logger } from "../server/logger";
import { prop_base } from "./prop_base";
/**
 * 装备生成方案
 * cfg name 不可更改
 * att 范围 rang
 * skill 指定技能 rang
 * 
 */
export class prop_equip extends prop_base {
    data: equip;
    icon: string = '⚔️';
    constructor(data) {
        super(data);
        if (data.data instanceof equip) {
            this.data = data.data;
            this.cfg_id = data.data.tpl_id;
        } else {
            // TODO:内存优化
            this.data = new equip();
            this.cfg_id = data.data.tpl_id;
            this.data.reload(data.data)
        }
    }
    getStyleName(){
        return `${this.icon}${this.data.name}⭐️${app.BN(this.score)}`;
    }
    use(tag: player, num: number): boolean {
        let jude = tag.wear_equip(this.data);
        if (jude) {
            this.num = 0;
            tag.update_attributes();
            tag.sendMsg(template.default, '装备成功.');
        } else {
            tag.sendMsg(template.default, '装备失败.最多可携带6件装备');
        }
        return jude;
    }
    look(tag: player) {
        return {template:template.panel_equip,data:this.data.get_panel()}
    }
}